#pragma once

#include <memory>
#include <functional>
#include "event_loop.h"
#include "inet_address.h"

namespace uvpp
{
	class TCPConnection;

	using TCPConnectionPtr = std::shared_ptr<TCPConnection>;
	using WriteCallback = std::function<void ()>;
	using OnMessageCallback = std::function<void(TCPConnectionPtr, const char*, ssize_t)>;

	class TCPConnection : public std::enable_shared_from_this<TCPConnection>
	{
	public:
		TCPConnection(EventLoop* loop, std::string& name, TCPPtr client);
		virtual ~TCPConnection();

		void close();
		void setMessageCallback(OnMessageCallback callback);
		void setCloseConnection();

	private:
		std::string _name;
		EventLoop* _loop;
		TCPPtr _client;

		OnMessageCallback _onMessageCallback;
	};

	
}
